var bn;
$(document).ready(function(){
	bn = navigator.appName;
});
function prevStep(){
	if(bn=='Microsoft Internet Explorer'){
		window.location.href = "../home/vp_add.jsp";
	}else if(bn=='Netscape'){
		window.location.href="home/vp_add.jsp";
	}else if(bn=='Opera'){
		window.location.href = "./home/vp_add.jsp";
	}
}
function validateToSubmit(){
	var i = 0;
	var stop = 0;
	var reg = /^\s+|\s+$/g;
	$('input[id=option_content]').each(function(){
		var content = $(this).val();
		content = content.replace(reg,"");
		i++;
		if(content==""){
			stop++;
			alert("第"+i+"项【内容】不能为空");
		}
	});
	var j = i;
	i = 0;
	$('input[id=option_image]').each(function(){
		var image_path = $(this).val();
		if(image_path!=""){
			i++;
			var extStart = image_path.lastIndexOf(".");
			var ext = image_path.substring(extStart,image_path.length).toUpperCase();
			if(ext!=".BMP"&&ext!=".PNG"&&ext!=".GIF"&&ext!=".JPG"&&ext!=".JPEG"){
				stop++;
				alert("第"+i+"项【图片】格式不符合[bmp,png,gif,jpeg,jpg]中的任意一种");
			}
		}
	});
	var k = i;
	if(k>0&&k<j){
		stop++;
		alert("如果您要上传选项的[图片]，请把每项的图片信息都填完");
	}
	if(stop==0){
		$('#vp_add2_form').submit();
	}
}
function sbar(st, col) {
	st.style.backgroundColor = '#EAF4FE';
}
function cbar(st) {
	st.style.backgroundColor = '';
}